﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using ChinaGS.Lian.ModuleRemoting;

public partial class pay_express_confirm_power : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SysCommon.checkUserLogin();

        if (!IsPostBack)
        {
            String cusNo = this.Request["power_num"];
            PowerPackage pp = RemotingClass.powerBillCheck(cusNo);

            //测试
            /*PowerPackage pp = new PowerPackage();
            pp.Status = true;
            pp.SerialNo = "123456789";
            pp.Message = "success";
            pp.StatusNo = "00";
            pp.PayMoney = 100;
            pp.PreMoney = 1;
            pp.NowMoney = 2;
            PowerBill pb1 = new PowerBill();
            pb1.PNBR = "123456789";
            pb1.PDTA = "20110712";
            pb1.MNBR = "100";
            pb1.WNBR = "10";
            pb1.USNM = "denver";
            pb1.USAD = "qd";
            pb1.PWNO = "123456";
            pb1.PSNO = "122";
            pb1.PPNO = "911";
            pb1.USNO = "1234";
            pb1.NOSA = "XXX";
            pb1.SSMN = "1000";
            PowerBill pb2 = new PowerBill();
            pb2.PNBR = "1234567890";
            pb2.PDTA = "20110713";
            pb2.MNBR = "100";
            pb2.WNBR = "10";
            pb2.USNM = "denver";
            pb2.USAD = "qd";
            pb2.PWNO = "123456";
            pb2.PSNO = "122";
            pb2.PPNO = "911";
            pb2.USNO = "1234";
            pb2.NOSA = "XXX";
            pb2.SSMN = "100,0";
            PowerBill[] pbs = new PowerBill[2] { pb1, pb2 };
            pp.PowerBiLL = pbs;*/

            //DataList2.DataSource = pp.PowerBiLL;
            //DataList2.DataBind();

            if (pp.Status)
            {
                if (!pp.StatusNo.Equals("00"))
                {
                    //测试使用
                    this.LabMessage.Text = pp.Message;
                    //调整内容正式时使用
                    //this.LabMessage.Text = RemotingClass.showErrorMessage(pp.StatusNo);                        
                    PanBill.Visible = false;
                }
                else
                {                   
                        LabMessage.Text = "尊敬的用户，您的账单信息如下，网上只能支付最近一次账单，请确认：";

                        LabNowMoney.Text = pp.NowMoney.ToString();
                        LabPayMoney.Text = pp.PayMoney.ToString();
                        LabPreMoney.Text = pp.PreMoney.ToString();

                        PowerBill pbTemp = pp.PowerBiLL[(pp.PowerBiLL.Length-1)];
                        LabMNBR.Text = pbTemp.MNBR;
                        LabNOSA.Text = pbTemp.NOSA;
                        LabPDTA.Text = pbTemp.PDTA;
                        LabPNBR.Text = pbTemp.PNBR;
                        LabPPNO.Text = pbTemp.PPNO;
                        LabPSNO.Text = pbTemp.PSNO;
                        LabPWNO.Text = pbTemp.PWNO;
                        LabSSMN.Text = pbTemp.SSMN;
                        LabUSAD.Text = pbTemp.USAD;
                        LabUSNM.Text = pbTemp.USNM;
                        LabUSNO.Text = pbTemp.USNO;
                        LabWNBR.Text = pbTemp.WNBR;


                        HidMNBR.Value = pbTemp.MNBR;
                        HidNOSA.Value = pbTemp.NOSA;
                        HidPDTA.Value = pbTemp.PDTA;
                        HidPNBR.Value = pbTemp.PNBR;
                        HidPPNO.Value = pbTemp.PPNO;
                        HidPSNO.Value = pbTemp.PSNO;
                        HidPWNO.Value = pbTemp.PWNO;
                        HidSSMN.Value = pbTemp.SSMN;
                        HidUSAD.Value = pbTemp.USAD;
                        HidUSNM.Value = pbTemp.USNM;
                        HidUSNO.Value = pbTemp.USNO;
                        HidWNBR.Value = pbTemp.WNBR;
                        HidCusNo.Value = cusNo;
                        HidNowMoney.Value = pp.NowMoney.ToString();
                        HidPreMoney.Value = pp.PreMoney.ToString();
                        HidPayMoney.Value = pp.PayMoney.ToString();

                        PanBill.Visible = true;                  
                }
            }
            else
            {
                this.LabMessage.Text = "本次操作失败，错误信息是：" + pp.Message + "请稍后重试！";
                PanBill.Visible = false;
                //显示查询失败
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("fill_power.aspx?"
                                            + "HidMNBR=" + HidMNBR.Value
                                            + "&HidNOSA=" + HidNOSA.Value
                                            + "&HidPDTA=" + HidPDTA.Value
                                            + "&HidPNBR=" + HidPNBR.Value
                                            + "&HidPPNO=" + HidPPNO.Value
                                            + "&HidPSNO=" + HidPSNO.Value
                                            + "&HidPWNO=" + HidPWNO.Value
                                            + "&HidSSMN=" + HidSSMN.Value
                                            + "&HidUSAD=" + HidUSAD.Value
                                            + "&HidUSNM=" + HidUSNM.Value
                                            + "&HidUSNO=" + HidUSNO.Value
                                            + "&HidWNBR=" + HidWNBR.Value                                            
                                            + "&HidCusNo=" + HidCusNo.Value
                                            + "&HidNowMoney=" + HidNowMoney.Value
                                            + "&HidPayMoney=" + HidPayMoney.Value
                                            + "&HidPreMoney=" + HidPreMoney.Value);
    }
}
